<template>
  <div class="content">
    <div>
      <el-button  type="primary"  size="mini" @click="goAdd" v-if="userInfo.shop_person_id">新增病例</el-button>
    </div>
    <div class="accountCon">
      <!--列表-->
      <el-row>
        <el-col :span="24">
          <el-table
            :data="list"
            size="small"
            border
            :cell-style="$style.cellStyle"
            :header-cell-style="$style.rowClass"
          >
            <ElTableColumn label="序号" type="index" width="55" />
            <ElTableColumn label="咨询时间"  prop="create_time" />
            <ElTableColumn label="病例单号" prop="case_no" />
            <ElTableColumn label="客户姓名"  prop="customer_name" />
            <ElTableColumn label="手机号"  prop="telephone" />
            <ElTableColumn label="主诊医生"  prop="doctor_name" />
            <ElTableColumn label="诊断结果"  prop="diagnose_category_three_text" />
            <ElTableColumn label="成交金额"  prop="bargain_money" />
            <ElTableColumn label="是否成交" prop="is_bargain">
            </ElTableColumn>
            <ElTableColumn label="操作"  fixed="right">
              <template  slot-scope="{ row }" >
                <span class="theme " @click="tapBtn('addOrder',row)" v-if="userInfo.shop_person_id"> 去开单</span>
                <span class="theme " @click="tapBtn('read',row)"> 查看</span>
                <!-- <span class="theme " @click="tapBtn('changeList',row)"> 变更记录</span> -->
                <span class="theme " @click="tapBtn('edit',row)" v-if="userInfo.shop_person_id"> 编辑</span>
              </template>  
            </ElTableColumn>
          </el-table>
          <pagination
            class="page tc mt10"
            :total="page.total"
            :page.sync="page.page"
            :limit.sync="page.limit"
            @pagination="getList"
          />
        </el-col>
      </el-row>
    </div>
  </div>
</template>

<script>
import pagination from '@/components/Pagination'
import { getCustomerCaseList} from '@/api/client';
import { mapGetters } from "vuex";

class Page {
  total = 0;
  page = 1;
  limit = 10
}


export default {
  name: 'ClassifyList',
  components: {
    pagination
  },
  props: {
    clienId: {
      type: String,
      default: ""
    },
     detail: {
      type: Object,
      default: () => {
        return {};
      }
    }
  },
  computed: {
    ...mapGetters(["userInfo"])
  },
  data () {
    return {
      page: new Page(), // 分页
      list: [], // 数据展示
    }
  },

  mounted () {
    this.getList();
  },
  methods: {
    goAdd () {
      const query = {
        types: "fourteen",
        detail: this.detail
      };
      this.$router.push({name:'新增病例',query})
    },
    // 获取列表
    getList (option) {
        getCustomerCaseList({...this.page,customer_id:this.clienId}).then(res => {
          this.list = res.data.list;
          this.page.total = res.data.dataCount;
        })
    },
    // 点击详情
    tapBtn (kind,row) {  
      const query = {
        caseId: row.id,
        id:row.customer_id,
        types: "fourteen",
        detail: this.detail,
        kind:kind
      };
      if(kind ==='changeList'){
        this.$router.push({name:'变更记录',query})
      }else if(kind == 'addOrder'){
        this.$router.push({name:'病例订单列表',query})
      }else{
        this.$router.push({name:'新增病例',query})
       }
    },

  }
}
</script>

<style lang="scss" scoped>

.bgW {
  background: #fff;
  border-radius: 3px;
  margin-bottom: 20px;
}
.el-form-item {
  margin: 5px  40px  3px 0 ;
}
.el-input--mini{
  width: 120px; 
}
.el-select{
  width: 120px;
}
.el-date-editor.el-input, .el-date-editor.el-input__inner{
  width: 200px; 
}
.el-form-item{
  margin: 5px 10px 3px 0 ;
}

.accountCon{
    background: #fff;
    margin-top: 30px;
}
</style>
